import { createStore } from 'vuex'

// 创建一个新的 store 实例
const store = createStore({
    state() {
        return {
            current: -1,
            pageIndex: -1,
            resultList: [
                { key: '昵称', value: '' },
                { key: '主音色', value: '' },
                { key: '听感特点', value: '' },
                { key: '共鸣腔体', value: '' },
                { key: '声音年龄', value: '' },
                { key: '音色冷暖', value: '' },
                { key: '声音伴侣', value: '' },
                { key: '直播方向', value: '' },
                { key: '音色等级', value: '' },
            ],
            list: [
                {
                    title: '情感文',
                    content: '111111111111111111',
                },
                {
                    title: '疯批类',
                    content: '222222222222222222',
                },
            ],
        }
    },
    mutations: {
        setState(state, object) {
            console.log(object);
            for (const key in object) {
                state[key] = object[key]
                if (key == 'resultList' || key == 'list') {
                    console.log("数据持久化-存储");
                    localStorage.setItem(key, JSON.stringify(object[key]))
                }
            }
        }
    }
})

export default store